<?php

namespace App\V3\V3_1\Services;

use App\V3\V3_1\Models\StoragesModel;

class StoragesService
{
    //仓库列表
    static public function list($parentId, $data)
    {
        return StoragesModel::getStorageList($parentId, $data);
    }

    //仓库下拉列表
    static public function storageSelect($mainId)
    {
        return StoragesModel::getStorageSelect($mainId);
    }

    //检查仓库信息是否存在
    static public function checkStoragesInfo($data)
    {
        $checkStorage = StoragesModel::where([
            'storage_name' => $data['storage_name'],
            'storage_address' => $data['storage_address'],
            'main_id' => $data['main_id'],
        ])
            ->where('delete_flag', 0)
            ->first();

        if(!empty($checkStorage)) {
            return true;
        }
        else {
            return false;
        }
    }
}
